
import dayjs from 'dayjs'


import { ref } from 'vue'

import { getDictionaryList } from '/@/views/teacher/home/index'



export const ycActionList: any = ref([])
getDictionaryList('ycAction', ycActionList)
export const ycZtList: any = ref([])
getDictionaryList('ycZt', ycZtList)
export const ycSourceList: any = ref([])
getDictionaryList('ycSource', ycSourceList)


export function createColumns() {

    return [
        {
            title: '序号',
            key: 'index',
            dataIndex: 'index',
            align: 'center',
            fixed: true,
            width: 60,
        },
        {
            title: '科目',
            dataIndex: 'kmmc',
            key: 'kmmc',
            align: 'center',
            width: 160,
            customRender: ({ record }) => {
                return `${record.kmdm}(${record.kmmc})`
            },
        },
        {
            title: '题目标题',
            key: 'tmbh',
            dataIndex: 'tmbh',
            align: 'center',
        },
        {
            title: '异常类型',
            dataIndex: 'ycName',
            key: 'ycName',
            align: 'center',
        },
        {
            title: '异常备注',
            dataIndex: 'ycBz',
            key: 'ycBz',
            align: 'center',
            ellipsis: true,
            customRender: ({ text }) => {
                return text || '--'
            },
        },
        {
            title: '异常来源',
            key: 'ycSource',
            dataIndex: 'ycSource',
            align: 'center',
            customRender: ({ text }) => {
                return ycSourceList.value?.find(item => item.value === text)?.label || ''
            },
        },
        {
            title: '异常状态',
            key: 'ycZt',
            dataIndex: 'ycZt',
            align: 'center',
            customRender: ({ text }) => {
                return ycZtList.value?.find(item => item.value === text)?.label || ''
            },
        },
        {
            title: '是否证实',
            key: 'confirmYcFlag',
            dataIndex: 'confirmYcFlag',
            align: 'center',
            customRender: ({ text }) => {
                return text ? '已证实' : '待证实'
            },
        },
        {
            title: '证实类型',
            key: 'confirmYcAction',
            dataIndex: 'confirmYcAction',
            align: 'center',
            customRender: ({ text }) => {
                return ycActionList.value?.find(item => item.value === text)?.label || ''
            },
        },
        {
            title: '上报人',
            key: 'createAccount',
            dataIndex: 'createAccount',
            align: 'center',
            customRender: ({ record }) => {
                if (!record.createAccount) return ''
                return `(${record.createName})${record.createAccount}`
            },
        },
        {
            title: '上报时间',
            key: 'createTime',
            dataIndex: 'createTime',
            align: 'center',
            width: 200,
            customRender: ({ record }) => {
                return dayjs(record.createTime).format('YYYY-MM-DD HH:mm')
            },
        },

        {
            title: '操作',
            key: 'handle',
            align: 'center',
            width: 100,
            fixed: 'right',
        },
    ]
}






